import { Route } from 'react-router-dom';
import { getToken } from '../utils/storage';

export  function AuthRoute(props) {
  const { component: Comp, path, ...restProps } = props;
  return (
    <Route
     {...restProps}
      path={path}
      render={(props) => {
        console.log(props);
        if (!!getToken()) {
          return <Comp {...props}></Comp>;
        }
        props.history.push('/login');
      }}
    ></Route>
  );
}
